{% extends "base.html" %}

{% block title %}数据字典 - 网站管理后台{% endblock %}

{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
    <h1 class="h2">数据字典</h1>
    <div class="btn-toolbar mb-2 mb-md-0">
        <div class="btn-group me-2">
            <a href="{{ url_for('web.add_data_dictionary') }}" class="btn btn-sm btn-outline-secondary">
                <i class="fas fa-plus"></i> 添加字典
            </a>
        </div>
    </div>
</div>

<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th>ID</th>
                <th>编码</th>
                <th>名称</th>
                <th>分类</th>
                <th>描述</th>
                <th>排序</th>
                <th>状态</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for dictionary in dictionaries %}
            <tr>
                <td>{{ dictionary[0] }}</td>
                <td>{{ dictionary[1] }}</td>
                <td>{{ dictionary[2] }}</td>
                <td>{{ dictionary[3] or '-' }}</td>
                <td>{{ dictionary[4] or '-' }}</td>
                <td>{{ dictionary[5] }}</td>
                <td>
                    {% if dictionary[6] == 1 %}
                        <span class="badge bg-success">启用</span>
                    {% else %}
                        <span class="badge bg-secondary">禁用</span>
                    {% endif %}
                </td>
                <td>{{ dictionary[7] }}</td>
                <td>
                    <a href="{{ url_for('web.dictionary_items', dictionary_id=dictionary[0]) }}" class="btn btn-sm btn-outline-info">
                        <i class="fas fa-list"></i> 字典项
                    </a>
                    <a href="{{ url_for('web.edit_data_dictionary', code=dictionary[1]) }}" class="btn btn-sm btn-outline-primary">
                        <i class="fas fa-edit"></i> 编辑
                    </a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}